﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using TaxData.Tax;

namespace TaxBiz.Tax
{
    /// <summary>
    /// 综合查询逻辑层
    /// </summary>
    public class ZongheQueryBiz
    {
        /// <summary>
        /// 获取列表
        /// </summary>
        public static DataTable GetList(string strWhere, int pageSize, int page, ref int allCount)
        {
            DataTable dt = ZongheQueryData.GetList(strWhere, pageSize, page, ref allCount);
            if (dt != null)
            {
                dt.Columns.Add("RequireTax");
                dt.Columns.Add("CompleteTax");
                dt.Columns.Add("BujiaoTax");
                dt.Columns.Add("startDate1");
                dt.Columns.Add("endDate1");
                dt.Columns.Add("TaxComDate1");
                TaxBiz.SysConfig.TaxsBiz tb = new SysConfig.TaxsBiz();
                foreach (DataRow dr in dt.Rows)
                {
                    Dictionary<string, decimal> requireTaxDic = new Dictionary<string, decimal>();
                    Dictionary<string, decimal> completeTaxDic = new Dictionary<string, decimal>();
                    tb.GetTaxDescDic(dr, out requireTaxDic, out completeTaxDic);

                    foreach (KeyValuePair<string, decimal> pair in requireTaxDic)
                    {
                        dr["RequireTax"] += pair.Key + ":" + pair.Value.ToString() + "<br/>";
                    }
                    foreach (KeyValuePair<string, decimal> pair in completeTaxDic)
                    {
                        dr["CompleteTax"] += pair.Key + ":" + pair.Value.ToString() + "<br/>";
                    }
                    if (dr.Table.Columns.Contains("startDate"))
                    {
                        dr["startDate1"] = BaseData.UI.PageContext.FormatData<DateTime>(dr["startDate"], "yyyy-MM-dd");
                    }
                    if (dr.Table.Columns.Contains("endDate"))
                    {
                        dr["endDate1"] = BaseData.UI.PageContext.FormatData<DateTime>(dr["endDate"], "yyyy-MM-dd");
                    }
                    if (dr.Table.Columns.Contains("TaxComDate"))
                    {
                        dr["TaxComDate1"] = BaseData.UI.PageContext.FormatData<DateTime>(dr["TaxComDate"], "yyyy-MM-dd");
                    }
                }
            }
            return dt;
        }
    }
}
